package com.brkj.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class TimeHelp {
	
	// longStr = "1256006105375";  
	public static String LongTOFormat(String longStr) {

		Date date = new Date(Long.parseLong(longStr));
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm");
		
		return formatter.format(date);
	}
	
	public static long FormatToLong(String sDt, String format){
		SimpleDateFormat sdf= new SimpleDateFormat(format);
		Date dt2 = null;
		long lTime = 0;
		try {
			dt2 = sdf.parse(sDt);
			lTime = dt2.getTime();
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		return lTime;
	}
	
	public static String LongTOFormatByCustom(String longStr, String format){
		Date date = new Date(Long.parseLong(longStr));
		SimpleDateFormat formatter = new SimpleDateFormat(format);
		
		return formatter.format(date);
	}
	
	public static String HavessToNoss(String timeStrWithss){
		Long timeLong = TimeHelp.FormatToLong(timeStrWithss, "MM-dd HH:mm:ss");
		String timeStr = TimeHelp.LongTOFormatByCustom(Long.toString(timeLong), "MM-dd HH:mm");
		return timeStr;
	}
	
	public static String geTime(){
		Date date=new Date();   
		SimpleDateFormat df=new SimpleDateFormat("MM-dd HH:mm:ss");   
		String time=df.format(date);
		return time;
	}

	public static String geTime(String format){
		Date date=new Date();
		SimpleDateFormat df=new SimpleDateFormat(format);
		String time=df.format(date);
		return time;
	}

	public static Long geLongTime(){
		Long time = System.currentTimeMillis();
		return time;
	}
}
